package org.testmyapp.entities;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.testmyapp.persistence.BusinessObjectMarker;

@Entity
public class AccountingMedical extends AbsProcessRelatedObject implements
		BusinessObjectMarker {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2856044138749424824L;

	public static String tableName = "AccountingMedical";

	@Id
	private Integer id;
	@ManyToOne
	@JoinColumn(name = "contract_id_fk")
	private Contract contract;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Contract getContract() {
		return contract;
	}

	public void setContract(Contract contract) {
		this.contract = contract;
	}

	public boolean equals(Object o) {
		if (o == this)
			return true;
		if (!(o instanceof AccountingMedical) || o == null)
			return false;
		AccountingMedical other = (AccountingMedical) o;
		if ((this.getId() == null && other.getId() != null)
				|| (!this.getId().equals(other.getId()))) {
			return false;
		}
		if ((this.getContract() == null && other.getContract() != null)
				|| !this.getContract().equals(other.getContract())) {
			return false;
		}
		return true;
	}

	public String toString() {
		String result = "";
		if(contract != null) {
			result += "ACCMED: " + id + "(" + contract.getId() + ")";
			return result;
		}
		result += "ACCMED: " + id + "(" + contract + ")";
		return result;
	}

}
